package com.supermap.originTest;

import com.supermap.data.*;
import com.supermap.data.processing.OSGBCacheBuilder;
import com.supermap.data.processing.PyramidSplitType;
import com.supermap.data.processing.VertexOptimizationType;
import com.supermap.realspace.CacheFileType;


public class Tile {
    public static void main(String[] args) {



        Workspace ws = new Workspace();
        WorkspaceConnectionInfo info = new WorkspaceConnectionInfo();
        info.setServer("E:\\MapData\\202409\\0\\0\\workspace.smwu");
        info.setType(WorkspaceType.SMWU);
        ws.open(info);
        Datasource datasource = ws.getDatasources().get(0);
        /*DataImport3D dataImport = new DataImport3D();
        ImportSettingRVT rvt = new ImportSettingRVT();
        rvt.setImportMode(ModelImportMode.NONE);
        rvt.setTargetDatasetName("datasource");
        rvt.setTargetDatasource(datasource);
        rvt.setSourceFilePath("/home/rvt/test.rvt");
        rvt.setTargetPriCoordSys(PrjCoordSys.fromEPSG(4326));
        rvt.setMaterialLibraryPath("/home/rvt/Materials");
        rvt.setDisplayStyle(DisplayStyle.Realistic);
        dataImport.getImportSettings().add(rvt);
        ImportResult3D result3D = dataImport.Run();
        if (result3D.GetFailedSettings() != null && result3D.GetFailedSettings().length > 0) {
            System.out.println("导入失败");
        }*/

        System.out.println("开始生成S3M");
        OSGBCacheBuilder builder =new OSGBCacheBuilder((DatasetVector)datasource.getDatasets().get("zjxkDataSource"),
                "E:\\MapData\\202409\\0\\0\\cache","dgnTest");
        builder.setCacheVersion(S3MVersion.VERSION_301);
        System.out.println(builder.getCompressedTextureType());
        //
	    builder.setCompressedTextureType(CompressedTextureType.CRNDXT5);
        builder.setAttributeExtentType(AttributeExtentType.S3MD);
        builder.setFileType(CacheFileType.S3MB);
        builder.setVertexOptimizationType(VertexOptimizationType.VO_MESHOPT);
        builder.setTilePyramidSplitType(PyramidSplitType.QuadTree);
        //Map<Integer,Double> map = new HashMap<>();
        //map.put(1,0.75);
        //map.put(2,0.5);
        //map.put(3,0.25);
        //builder.setSimplifyPercent(map);
        //builder.setMultiTextureMode(MultiTextureMode.DOUBLECHANNEL);
        //builder.setSecondTextureType(SecondTextureType.SHADOWMAP);
        //builder.setLimitTextureSize(CacheLimitTextureSize.LimitSize_4096);
       // builder.setVertexWeightMode(VertexWeightMode.VWM_HEIGHT);
       // builder.setMaterialType(MaterialType.NORMAL);

        //System.out.println(builder.get);
        boolean result = builder.build();
        if(result) {
            System.out.println("生成S3M成功");
        }



    }

}
